package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsRoleMapper;
import com.qf.pojo.DtsRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author jiangjingbo
 * @version V1.0
 * @Project java2203
 * @Package com.qf.service
 * @Description:
 * @Date 2022/6/16 15:34
 */

/**
 * 根据id查询用户角色
 */
@Service
public class RoleServiceimpl implements  RoleService{
    @Autowired
    private DtsRoleMapper roleMapper;
    @Override
    public Set<String> findRoleByRolsId(Integer[] ids) {
        QueryWrapper<DtsRole> queryWrapper =new QueryWrapper<>();
        queryWrapper.in("id",ids);
        queryWrapper.eq("deleted",false);
        queryWrapper.eq("enabled",true);

        List<DtsRole> roles = roleMapper.selectList(queryWrapper);
        Set<String> dtsRoles = new HashSet<>();
        for (DtsRole role : roles) {
            dtsRoles.add(role.getName());
            System.out.println("role.getName()======"+role.getName());
        }
        return dtsRoles;
    }
}
